import requests

from .base import Base


class Post(Base):
    def add(self, userid, name, mobile, department=None):
        ACCESS_TOKEN = self.token()
        url = self.url + f"/create?access_token={ACCESS_TOKEN}"
        json = {
            "userid": userid,
            "name": name,
            "mobile": f"+86 {mobile}",
            "department": department
        }
        return self.send("post", url, json=json)

    def update(self, userid, name):
        ACCESS_TOKEN = self.token()
        url = self.url + f"/update?access_token={ACCESS_TOKEN}"
        json = {
            "userid": userid,
            "name": name
        }
        return self.send("post", url, json=json)
